<?
	class InputNumber extends Input
	{
		var $nLength;
		var $nSize;
		var $nMinValue;
		var $nMaxValue;
		var $bShowCalculator;
		var $bAutoSize = true;

    function InputNumber( $cLabel, $cField, $cValue = '', $bMandatory = false, $nLength = 5) 
		{
			$this->Input( $cLabel, $cField, $cValue, $bMandatory );
			$this->setLength( $nLength );
		}
	function make()    
		{
			// Si esta setea como Oculto
			if ( $this->bHidden )
			{
				if ( is_array( $this->cValue)  ) $this->cValue = implode( ",", $this->cValue );
				return parent::make();
			}
			// make comun
			$this->setOnBlur( "return checkNumber(this, \"" . $this->cLabel . "\" , " . ($this->bMandatory ? 1:0) . " );", true );						
			$cReturn = "";
			$cPropiedades = $this->getProperties();
			$cEventos     = $this->getEvents();
			$nMaxEntero = intval($this->nLength);
			$nMaxDecimal = ($this->nLength * 10 ) % 10;
			// Queda el Maximo y minimo como cantidad de caracteres (incluyendo el punto)
			$nMaximo = ($nMaxDecimal == 0) ? $nMaxEntero : $nMaxEntero + 1 + $nMaxDecimal;
			if ( $this->nSize ) $cPropiedades .= " size='" . $this->nSize . "' ";
			$cReturn .= "<input type='text' style='text-align:right' $cPropiedades $cEventos name='" . $this->cField ."' id='" . $this->cField ."' onkeypress='return checkNumberEdit(this, $nMaxDecimal , event);'  value='" . $this->cValue ."' maxlength='$nMaximo' />";
			return $cReturn;    
		}
	function setSize( $nSize )
		{
			$this->nSize = $nSize;
			$this->bAutoSize = false;
		}
	function setLength( $nLength )
		{
			if ( $nLength == '' || !is_numeric($nLength)  ) return false;
			$this->nLength = $nLength;
			// Si no tiene definido el ancho lo setea de escalonadamente por la longitud del campo
			if ( $this->bAutoSize ) 
			{
				$this->nSize = ( $this->nLength <= 5 ) ? 3 : 10;
			}
		}
	}
?>
